package com.prs.crm.action.approval;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.domain.approval.AppNumberSet;
import com.prs.crm.domain.approval.Process;
import com.prs.crm.domain.approval.ShenQingType;
import com.prs.crm.service.approval.AppNumberSetService;
import com.prs.crm.service.approval.ShenQingTypeService;

public class AppNumberSetAction extends BaseAction{
	private PaginationSupport pagination;
	private Integer[] ids;
	private AppNumberSet numberSet;
	private AppNumberSetService appNumberSetService;
	private List<ShenQingType> shenQingTypes;
	private ShenQingTypeService shenQingTypeService;
	private String[] rightSelectValue;                  //选中的模板
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	public Integer[] getIds() {
		return ids;
	}
	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	public AppNumberSet getNumberSet() {
		return numberSet;
	}
	public void setNumberSet(AppNumberSet numberSet) {
		this.numberSet = numberSet;
	}
	public AppNumberSetService getAppNumberSetService() {
		return appNumberSetService;
	}
	public void setAppNumberSetService(AppNumberSetService appNumberSetService) {
		this.appNumberSetService = appNumberSetService;
	}
	public List<ShenQingType> getShenQingTypes() {
		return shenQingTypes;
	}
	public void setShenQingTypes(List<ShenQingType> shenQingTypes) {
		this.shenQingTypes = shenQingTypes;
	}
	public ShenQingTypeService getShenQingTypeService() {
		return shenQingTypeService;
	}
	public void setShenQingTypeService(ShenQingTypeService shenQingTypeService) {
		this.shenQingTypeService = shenQingTypeService;
	}
	public String[] getRightSelectValue() {
		return rightSelectValue;
	}
	public void setRightSelectValue(String[] rightSelectValue) {
		this.rightSelectValue = rightSelectValue;
	}
	//////////////////////////////////////////////////////////////////
	@Action("listNumberSet")
	public String listAppNumberSet(){
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(AppNumberSet.class);
		this.setPagination(this.appNumberSetService.listByPage(criteria, 
				this.getPaginationHelper().prepare(pagination)));
		return SUCCESS;
	}
	@Action("editNumberSet")
	public String editAppNumberSet(){
		this.shenQingTypes = this.shenQingTypeService.getAllShenQingType();
		return SUCCESS;
	}
	@Action(value="saveAppNumberSet",results={
		@Result(name="success", type="redirect", location="listNumberSet"),
		@Result(name="error", type="chain", location="editNumberSet")
	})
	public String saveAppNumberSet(){
//		this.appNumberSetService
		this.getAppNumberSetService().save(numberSet);
		return SUCCESS;
	}
	@Action(value="removeAppNumberSet",results={
			@Result(name="success", type="redirect", location="listNumberSet"),
			@Result(name="error", type="chain", location="listNumberSet")
		})
	public String removeAppNumberSet(){
		if(ids==null){
			this.setPrompt("请选择一行数据!");
			return ERROR;
		}
		this.appNumberSetService.batchRemove(ids);
		return SUCCESS;
	}
	
}
